import {
	login,
	getUserInfo
} from "@/api/user/index.js"
import {
	updateToken
} from '@/utils/updateToken.js'
export default {
	methods: {
		async handleLogin() {
			if (!uni.getStorageSync('token')) {
				return new Promise((resolve, reject) => {
					wx.getSystemInfo({
						success: async (res) => {
							console.log(res.environment, "登录环境")
							await updateToken()
							const userInfoRes = await getUserInfo({})
							const {
								isBusiness
							} = userInfoRes.data
							this.$store.dispatch('setUserInfo', userInfoRes.data)
							//TODO

							this.$store.dispatch('setIsCustomerPage', res.environment ===
								'wxwork' ? false :
								!isBusiness)
							resolve()
						},

					})
				})

			}
		}

	}

}